class DescriptorsController < ApplicationController
  load_and_authorize_resource

  def selector_descriptors_list
    @descriptors = Descriptor.search_selector(params[:search_name], params[:page])
      render :partial=>'descriptors/selector_descriptors_list', :locals => {:search_name => params[:search_name]}, :layout=>false
  end
  
  def selector_descriptors_list_from_paginate
      @descriptors = Descriptor.search_selector(params[:search_name], params[:page])
  end

  # GET /descriptors
  # GET /descriptors.xml
  def index
    @descriptors = Descriptor.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @descriptors }
    end
  end

  # GET /descriptors/1
  # GET /descriptors/1.xml
  def show
    @descriptor = Descriptor.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @descriptor }
    end
  end

  # GET /descriptors/new
  # GET /descriptors/new.xml
  def new
    @descriptor = Descriptor.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @descriptor }
    end
  end

  # GET /descriptors/1/edit
  def edit
    @descriptor = Descriptor.find(params[:id])
  end

  # POST /descriptors
  # POST /descriptors.xml
  def create
    @descriptor = Descriptor.new(params[:descriptor])

    respond_to do |format|
      if @descriptor.save
        flash[:notice] = 'Descriptor was successfully created.'
        format.html { redirect_to(@descriptor) }
        format.xml  { render :xml => @descriptor, :status => :created, :location => @descriptor }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @descriptor.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /descriptors/1
  # PUT /descriptors/1.xml
  def update
    @descriptor = Descriptor.find(params[:id])

    respond_to do |format|
      if @descriptor.update_attributes(params[:descriptor])
        flash[:notice] = 'Descriptor was successfully updated.'
        format.html { redirect_to(@descriptor) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @descriptor.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /descriptors/1
  # DELETE /descriptors/1.xml
  def destroy
    @descriptor = Descriptor.find(params[:id])
    @descriptor.destroy

    respond_to do |format|
      format.html { redirect_to(descriptors_url) }
      format.xml  { head :ok }
    end
  end
end
